package com.zxh.project.areachooseapplication;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2016/3/23.
 */
public class MyApp extends Application {
    private static MyApp app;
    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;
    private boolean isLogined;
    private String uid;
    private String sid;
    private String pwd;
    private String phone;
    private String nickname;
    private String head;
    private String token;//sisson


    public boolean isLogined() {
        return sharedPreferences.getBoolean("isLogined",false);
    }

    public SharedPreferences getSharedPreferences() {
        return sharedPreferences;
    }

    public SharedPreferences.Editor getEditor() {
        return editor;
    }

    public static MyApp getApp() {
        return app;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        this.app = this;
        initSharedpre();
        isLogined = false;
        //初始化极光推送
        initJpush();
        //百度地图初始化
//        SDKInitializer.initialize(getApplicationContext());

    }

    private void initSharedpre() {
        sharedPreferences = getSharedPreferences("userMsg", Context.MODE_PRIVATE);
        editor = sharedPreferences.edit();
    }


    private void initJpush() {
//        JPushInterface.setDebugMode(true);
//        JPushInterface.init(this);
//        JPushInterface.setLatestNotificationNumber(this,3);
    }

    public String getSid() {
        return sharedPreferences.getString("sid","-1");
    }

    public String getUid() {
        return sharedPreferences.getString("uid","-1");
    }

    public String getPwd() {
        return sharedPreferences.getString("pwd","-1");
    }

    public String getPhone() {
        return sharedPreferences.getString("phone","-1");
    }

    public String getNickname() {
        return sharedPreferences.getString("nickname","-1");
    }

    public String getHead() {
        return sharedPreferences.getString("head","-1");
    }

    public void setLogined(boolean logined) {
        editor.putBoolean("isLogined", logined);
        editor.commit();
    }

    public void setUid(String uid) {
        editor.putString("uid",uid);
        editor.commit();
    }

    public void setSid(String sid) {
        editor.putString("sid",sid);
        editor.commit();
    }

    public void setPwd(String pwd) {
        editor.putString("pwd",pwd);
        editor.commit();
    }

    public void setPhone(String phone) {
        editor.putString("phone",phone);
        editor.commit();
    }

    public void setNickname(String nickname) {
        editor.putString("nickname",nickname);
        editor.commit();
    }

    public void setHead(String head) {
        editor.putString("head",head);
        editor.commit();
    }
}
